package com.project.smarthome.common.util;

/**
 * 作者 lunanting on 2016/9/12 16 04.
 * <p/>
 * 邮箱：919530038@qq.com
 */
public class ClickFilter {

    public static final long INTERVAL = 800L; //防止连续点击的时间间隔
    public static final long KDCLICK = 350L; //防止连续点击的时间间隔
    private static long sLastClickTime = 0L; //上一次点击的时间
    private static long sLastkdClickTime = 0L; //上一次点击的时间

    public synchronized static boolean filter() {
        long time = System.currentTimeMillis();
        if ((time - sLastClickTime) > INTERVAL) {
            sLastClickTime = time;
            return false;
        }
        return true;
    }

    public synchronized static boolean kdfilter() {
        long time = System.currentTimeMillis();
        if ((time - sLastkdClickTime) > KDCLICK) {
            sLastkdClickTime = time;
            return false;
        }
        return true;
    }
}
